#include <QApplication>

#include "DGVVolumePlotVTK.h"
#include "DGVBlitzArrayCasterVTK.h"

#include "vtkImageData.h"
#include "vtkXMLImageDataWriter.h"

const int Size = 128;

typedef double plotType;

int main(int argc, char *argv[])
{
	QApplication app(argc,argv);
    Array<plotType,3> gaussian(Size,Size,Size);
    firstIndex x;
    secondIndex y;
    thirdIndex z;

    ///Generate Gaussian Function
    plotType amplitude = 100.0, stdDev_x = Size/2, stdDev_y = Size/2, stdDev_z = Size/2, x0 = 0, y0 = Size/2, z0 = 0;
    gaussian = amplitude*exp( -( (x-x0)/stdDev_x*(x-x0)/stdDev_x + (y-y0)/stdDev_y*(y-y0)/stdDev_y + (z-z0)/stdDev_z*(z-z0)/stdDev_z ) );

    ///Output to VTK XML Image (VTI) file
    DGVBlitzArrayCasterVTK<plotType> Blitz;
    vtkImageData *data = Blitz.arrayToVTKImageData(gaussian);

    vtkXMLImageDataWriter *XMLwriter = vtkXMLImageDataWriter::New();
        XMLwriter->SetFileName("gaussian.vti");
        XMLwriter->SetDataModeToBinary();
        XMLwriter->SetInput(data);
        XMLwriter->Write();

    DGVVolumePlotVTK volumePlot;
        volumePlot.setData(gaussian);
        volumePlot.generatePlot();
        volumePlot.generateAxes();

    volumePlot.show();

    app.exec();

    XMLwriter->Delete();
    data->Delete();

    return EXIT_SUCCESS;
}
